package com.atguigu.gmall.search.controller;

import com.atguigu.gmall.common.bean.ResponseVo;
import com.atguigu.gmall.search.pojo.SearchParamVo;
import com.atguigu.gmall.search.pojo.SearchResponseVo;
import com.atguigu.gmall.search.service.SearchService;
import io.swagger.annotations.Api;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ModelBuilder;

import java.util.List;

/**
 * @author Jia Fa
 * @create 2021-12-07 13:53
 */
@Controller
@Api("ES搜索方法")
public class SearchController {

    @Autowired
    private SearchService searchService;


    @GetMapping("search")
    public String querySearch(SearchParamVo paramVo, Model model){

        SearchResponseVo responseVo = this.searchService.querySearch(paramVo);

        model.addAttribute("response", responseVo);
        model.addAttribute("searchParam", paramVo);

        return "search";
    }
}
